﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Deparment_Worker_PassWordChange : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumDeparment);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {

        }
        else
        {

        }

    }
  
    protected void queding_Click(object sender, EventArgs e)
    {
        Int64 AccountId;
        string strSql;
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            if (NewPwd.Text.Trim() != ConfirmPwd.Text.Trim())
            {
                Response.Write("<script>window.alert('新密码与确认密码不一致');</script>");
            }
            else if (OldPwd.Text.Trim() == NewPwd.Text.Trim())
            {
                Response.Write("<script>window.alert('新密码不能和酒密码不一致！');</script>");
            }
            else
            {

                if (OldPwd.Text.Trim() != SysFun.PasswordDecrypt(SysFun.ToTrim(_Account.Pwd_Bid)))
                {
                    Response.Write("<script>window.alert('原密码不正确');</script>");

                }
                else
                {
                    AccountId = SysFun.ToLong(_Account.AccountId);
                    Db db = new Db();
                    strSql = "update Account set Pwd_Bid='" + SysFun.PasswordEncrypt(SysFun.ToTrim(NewPwd.Text)) + "' where AccountId=" + AccountId.ToString();
                    db.Command(strSql);
                    db.Close();
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "Account", strSql, "../Magage/ChangePwd.aspx");

                    Response.Write("<script>window.opener.location.reload();window.close();</script>");
                    Response.Write("<script>window.alert('修改密码成功');</script>");

                }

            }
        }
        else
        {
            Response.Write("<script>window.alert('你还没有登录,请登录后再修改!!!');</script>");
        }

    }
}
